/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.impulserobotics;

import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;

/**
 *
 * @author Sahil Jain
 */
public class BallLifter {

    Relay liftMotor;
    boolean currentlyPressed = false;
    boolean directionBWD = false;
    
    
    
    
    public BallLifter(int liftMotorPWM) {
        liftMotor = new Relay(liftMotorPWM);
    }

    public BallLifter() {
        liftMotor = new Relay(Constants.BALL_LIFTER_RELAY);
    }

    public void update(Joystick inJoy) {
        
        if(inJoy.getRawButton(Constants.BALL_LIFTER_FWD)){
            directionBWD = false;
        }else if(inJoy.getRawButton(Constants.BALL_LIFTER_BWD)){
            directionBWD = true;
        }
        update(inJoy.getRawButton(Constants.BALL_LIFTER_BUTTON));
    }

    public void update(boolean pressed) {
        if (pressed != currentlyPressed) {
            currentlyPressed = !currentlyPressed;
            if (currentlyPressed && directionBWD == false) {
                //liftMotor.set(Constants.BALL_LIFTER_SPEED);
                liftMotor.set(Relay.Value.kForward);
            if (currentlyPressed && directionBWD) {
                //liftMotor.set(Constants.BALL_LIFTER_SPEED);
                liftMotor.set(Relay.Value.kReverse);
            }
            } else {
                liftMotor.set(Relay.Value.kOff);
            }

        }

    }
}
    
